//
//  YHWaterFallCollectionVC.m
//  LyhToolsTest
//
//  Created by 李彦宏 on 2019/9/7.
//  Copyright © 2019 LYH.com. All rights reserved.
//

#import "YHWaterFallCollectionVC.h"

#import "YHCollectionViewLauout.h"
@interface YHWaterFallCollectionVC ()<UICollectionViewDelegate,UICollectionViewDataSource,YHCollectionViewLauoutDelegate>
@property (nonatomic, strong) UICollectionView *collectionview;


@end

@implementation YHWaterFallCollectionVC

- (void)viewDidLoad {
    [super viewDidLoad];
   
}
#pragma -mark ---------------------collectionView的代理和数据源方法---------------------------------
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 10;
}


- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    YHImageCell *cell = [YHImageCell codeCell:collectionView cellForItemAtIndexPath:indexPath];
    
    return cell;
}

- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    
}

//懒加载collectionview
- (UICollectionView *)collectionview
{
    if (!_collectionview) {
        YHCollectionViewLauout *layout=[[YHCollectionViewLauout alloc] init];
        layout.delegate = self;
        
        _collectionview=[[UICollectionView alloc] initWithFrame:CGRectMake(0, SafeAreaTopHeight, kScreenWidth, kScreenHeigth-SafeAreaTopHeight) collectionViewLayout:layout];
        _collectionview.dataSource=self;
        _collectionview.delegate=self;
        _collectionview.backgroundColor=[UIColor whiteColor];
        //支持分页
        _collectionview.pagingEnabled=NO;
        _collectionview.scrollEnabled=YES;
        _collectionview.alwaysBounceVertical = YES;//数据少时也能滚动
        [self.view addSubview:_collectionview];
    }
    return _collectionview;
}
@end
